package com.huawei.appgallery.appcomment.ui.view;

import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.Nullable;
import com.huawei.appgallery.appcomment.impl.bean.GetCommentResBean.WordsOfDevInfo;
import com.huawei.appgallery.foundation.service.common.protocol.AppDetailActivityProtocol;
import com.huawei.appgallery.foundation.service.common.protocol.AppDetailActivityProtocol.Request;
import com.huawei.appgallery.foundation.ui.framework.cardframe.bean.BaseCardBean;
import java.util.List;
import o.bcg.d;
import o.bcg.e;
import o.bcg.h;
import o.bmt;
import o.cii;
import o.cjk;
import o.cjm;
import o.cjo;
import o.ckt;
import o.ckv;
import o.clc;

public class CommentDevItemView extends LinearLayout implements OnClickListener {
    private ImageView ˊ;
    private String ˋ;
    private TextView ˎ;
    private TextView ˏ;
    private TextView ॱ;

    public CommentDevItemView(Context context) {
        this(context, null);
    }

    public CommentDevItemView(Context context, @Nullable AttributeSet attributeSet) {
        super(context, attributeSet);
        View inflate = ((LayoutInflater) context.getSystemService("layout_inflater")).inflate(d.ᐝ, this, true);
        this.ˎ = (TextView) inflate.findViewById(e.ˊʽ);
        this.ॱ = (TextView) inflate.findViewById(e.ꜝ);
        this.ˏ = (TextView) inflate.findViewById(e.ꜟॱ);
        this.ˏ.setText(h.ʼॱ);
        this.ˊ = (ImageView) inflate.findViewById(e.ᶫ);
        this.ˏ.setOnClickListener(new ckt(this));
        this.ˊ.setOnClickListener(new ckt(this));
    }

    public void ˎ(List<WordsOfDevInfo> list) {
        if (list == null || list.size() == 0) {
            setVisibility(8);
            return;
        }
        setVisibility(0);
        for (WordsOfDevInfo wordsOfDevInfo : list) {
            this.ˋ = wordsOfDevInfo.ˎˎ();
            this.ॱ.setText(wordsOfDevInfo.ˍ());
            this.ˎ.setText(wordsOfDevInfo.ˋˋ());
            if (TextUtils.isEmpty(wordsOfDevInfo.ˎˎ())) {
                this.ˏ.setVisibility(8);
                this.ˊ.setVisibility(8);
            } else {
                this.ˏ.setVisibility(0);
                this.ˊ.setVisibility(0);
            }
        }
    }

    public void onClick(View view) {
        String str = this.ˋ;
        if (!TextUtils.isEmpty(str) && getContext() != null) {
            if (!bmt.ˊ(getContext())) {
                ckv.ˎ(getContext().getString(h.ᐝʽ), 0);
            } else if (str.startsWith("html|")) {
                int indexOf = str.indexOf(124);
                if (indexOf != -1) {
                    str = str.substring(indexOf + 1);
                }
                clc.ॱ(view.getContext(), str);
            } else {
                BaseCardBean baseCardBean = new BaseCardBean();
                baseCardBean.ॱ(str);
                Context context = view.getContext();
                if (!cii.ˊ().ˊ(context, baseCardBean)) {
                    cjo appDetailActivityProtocol = new AppDetailActivityProtocol();
                    appDetailActivityProtocol.ˏ(new Request(str, null));
                    cjk.ˎ().ˋ(context, new cjm("appdetail.activity", appDetailActivityProtocol));
                }
            }
        }
    }
}
